package cn.shujuhai.workflow.controller.flow;

import cn.shujuhai.common.pluging.data.ResultVo;
import cn.shujuhai.workflow.domain.FormData;
import cn.shujuhai.workflow.domain.LeaveRequest;
import cn.shujuhai.workflow.service.flow.LeaveService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/workflow/leave")
@RequiredArgsConstructor
public class LeaveController {

    private final LeaveService leaveService;

    @PostMapping("/apply")
    public ResultVo<?> applyLeave(@RequestBody LeaveRequest leaveRequest) {
        return leaveService.applyLeave(leaveRequest);
    }

    @PostMapping("/approve1")
    public ResultVo<?> approveLeave1(@RequestParam String taskId, @RequestParam boolean approved) {
        return leaveService.approveLeave1(taskId, approved);
    }

    @PostMapping("/approve")
    public ResultVo<?> approveLeave(@RequestBody FormData formData) {
        return leaveService.approveLeave(formData);
    }
}